#include <reg52.h>
#include "key.h"

code uint8 maxheart[]={
	0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7
};
code uint8 minheart[]={
	0xFF,0xFF,0xDB,0x81,0x81,0xC3,0xE7,0xFF
};
int16 n;

void refresh_led()
{
	static uint8 j=0;
	uint8 x=200;
	P0=0xFF;
	switch(j)
	{
		case 0:ADDR0=0;ADDR1=0;ADDR2=0;break;
		case 1:ADDR0=1;ADDR1=0;ADDR2=0;break;
		case 2:ADDR0=0;ADDR1=1;ADDR2=0;break;
		case 3:ADDR0=1;ADDR1=1;ADDR2=0;break;
		case 4:ADDR0=0;ADDR1=0;ADDR2=1;break;
		case 5:ADDR0=1;ADDR1=0;ADDR2=1;break;
		case 6:ADDR0=0;ADDR1=1;ADDR2=1;break;
		case 7:ADDR0=1;ADDR1=1;ADDR2=1;break;
	}
	if(n>=0){
		P0=maxheart[j];
	}else if(n<0){
		P0=minheart[j];
	}
	//j++;
	if(j++==7)
	{
		j=0;
		n++;
		if(n>=2000)
		{
			n=-2000;
		}
	}
}

void main()
{
	P0=0xFF;
	ENLED=0;ADDR3=0;
	while(1){
		refresh_led();
	}
}